/* preparing citizen files */
data citizens;
 set sasuser.citizens;

/* re-coding negative items */
if IGneg1      eq 1 then IGneg1 = 5;
else if IGneg1 eq 2 then IGneg1	= 4;
else if IGneg1 eq 4	then IGneg1	= 2;
else if IGneg1 eq 5 then IGneg1	= 1;

/* re-coding negative items */
if IGneg2      eq 1 then IGneg2 = 5;
else if IGneg2 eq 2 then IGneg2	= 4;
else if IGneg2 eq 4	then IGneg2	= 2;
else if IGneg2 eq 5 then IGneg2	= 1;

/* constructing scales */
decision =sum(decision1,decision2,decision3);
procedure=sum(procedure1,procedure2,procedure3);
IG=sum(IGneg1,IGpos1,IGneg2,IGpos2);
trust=sum(TrustBedrijven,TrustConsumenten,TrustVakbonden,TrustRecht,TrustPolpart,TrustFedparl,TrustFedreg,TrustEU,TrustECB);
internal=sum(internal1,internal2);
external=sum(external1,external2);

/* mean scores */
meandecision=decision/3;
meanprocedure=procedure/3;
IGMean=IG/4;
Trustmean=trust/9;
internalmean=internal/2;
externalmean=external/2;

/* scoring of variables on a scale 0 - 1 */
nmeandecision =(meandecision -1)/(7-1 );
nmeanprocedure=(meanprocedure-1)/(7-1 );
nLeft_Right   =(Left_Right   -1)/(10-1);
nIGMean       =(IGMean       -1)/(5-1 );

/* category left-right */
if Left_Right in (0,1,2,3)  then lr=1;
if Left_Right in (4,5,6)    then lr=2;
if Left_Right in (7,8,9,10) then lr=3;

/* category decision */
if meandecision gt 5                        then decision=3;
if meandecision le 5 and meandecision gt 3  then decision=2;
if meandecision le 3                        then decision=1;
 
run;

/* reliability analysis */
proc corr data=citizens alpha; var decision1 decision2 decision3; 
proc corr data=citizens alpha; var procedure1 procedure2 procedure3; 
proc corr data=citizens alpha; var TrustBedrijven TrustConsumenten TrustVakbonden TrustRecht TrustPolpart TrustFedparl TrustFedreg TrustEU TrustECB; 
run;

/* preparing company files */
data companies; 
 set sasuser.companies;

 /* re-coding negative items */
if IGneg1      eq 1 then IGneg1 = 5;
else if IGneg1 eq 2 then IGneg1	= 4;
else if IGneg1 eq 4	then IGneg1	= 2;
else if IGneg1 eq 5 then IGneg1	= 1;

/* re-coding negative items */
if IGneg2      eq 1 then IGneg2 = 5;
else if IGneg2 eq 2 then IGneg2	= 4;
else if IGneg2 eq 4	then IGneg2	= 2;
else if IGneg2 eq 5 then IGneg2	= 1;

/* constructing scales */
decision =sum(decision1,decision2,decision3);
procedure=sum(procedure1,procedure2,procedure3);
IG=sum(IGneg1,IGpos1,IGneg2,IGpos2);
trust=sum(TrustBedrijven,TrustConsumenten,TrustVakbonden,TrustRecht,TrustPolpart,TrustFedparl,TrustFedreg,TrustEU,TrustECB);
internal=sum(internal1,internal2);
external=sum(external1,external2);

/* mean scores */
meandecision=decision/3;
meanprocedure=procedure/3;
IGMean=IG/4;
Trustmean=trust/9;
internalmean=internal/2;
externalmean=external/2;

/* scoring of variables on a scale 0 - 1 */
nmeandecision =(meandecision -1)/(7-1 );
nmeanprocedure=(meanprocedure-1)/(7-1 );
nLeft_Right   =(Left_Right   -1)/(10-1);
nIGMean       =(IGMean       -1)/(5-1 );

/* category left-right */
if Left_Right in (0,1,2,3)  then lr=1;
if Left_Right in (4,5,6)    then lr=2;
if Left_Right in (7,8,9,10) then lr=3;

/* category decision */
if meandecision gt 5                        then decision=3;
if meandecision le 5 and meandecision gt 3  then decision=2;
if meandecision le 3                        then decision=1;
 
/* category left-right */
if Left_Right in (0,1,2,3)  then lr=1;
if Left_Right in (4,5,6)    then lr=2;
if Left_Right in (7,8,9,10) then lr=3;

proc corr data=companies alpha; var decision1 decision2 decision3; 
proc corr data=companies alpha; var procedure1 procedure2 procedure3; 
proc corr data=citizens alpha; var TrustBedrijven TrustConsumenten TrustVakbonden TrustRecht TrustPolpart TrustFedparl TrustFedreg TrustEU TrustECB; 
run;
